<template>
  <h1>一个人的信息</h1>
  <h2>姓名：{{ name }}</h2>
  <h2>年龄：{{ age }}</h2>
  <h3>工种：{{ job.type }}</h3>
  <h3>工资：{{ job.salary }}</h3>
  <button @click="changeInfo">修改人的信息</button>
</template>

<script>
import { ref } from "vue";
export default {
  name: "App",
  setup() {
    let name = ref("张三"); // RefImpl
    let age = ref(18);
    let job = ref({
      type: "前端工程师",
      salary: "30k",
    });

    function changeInfo() {
      // console.log(name, age); // 引用实现的实例对象——引用对象
      console.log(job.value); // Proxy
      // name = "李四";
      // age = 19;
      // console.log(name, age); // 数据改了，Vue监测不到
      name.value = "李四";
      age.value = 19;
      job.value.salary = "60k";
      // console.log(name, age);
    }

    return {
      name,
      age,
      job,
      changeInfo,
    };
  },
};
</script>
